package com.mallcloud.mall.app.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.mall.api.entity.MallPointsInRecordModel;
import com.mallcloud.mall.mall.api.entity.MallPointsOutRecordModel;
import com.mallcloud.mall.mall.service.MallPointsInRecordService;
import com.mallcloud.mall.mall.service.MallPointsOutRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "app-积分收入|支出管理")
@RestController
@AllArgsConstructor
@RequestMapping("/app/pointsRedeemRecord")
public class AppPointLogController {
	private final MallPointsInRecordService mallPointsInRecordService;
	private final MallPointsOutRecordService mallPointsOutRecordService;

	@ApiOperation("积分收入分页")
	@GetMapping("/inPage")
	public R<IPage<MallPointsInRecordModel>> inPage(Page page, MallPointsInRecordModel model) {
		return R.ok(mallPointsInRecordService.page(page, Wrappers.lambdaQuery(model).orderByDesc(MallPointsInRecordModel::getUpdateTime)));
	}

	@ApiOperation("积分支出分页")
	@GetMapping("/outPage")
	public R<IPage<MallPointsOutRecordModel>> outPage(Page page, MallPointsOutRecordModel model) {
		return R.ok(mallPointsOutRecordService.page(page, Wrappers.lambdaQuery(model).orderByDesc(MallPointsOutRecordModel::getUpdateTime)));
	}

}
